# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : 手写数字识别_数据可视化展示.py
# @Author: dongguangwen
# @Date  : 2025-01-19 19:37
import matplotlib.pyplot as plt
import pandas as pd
from collections import Counter


# 1.读取数据
data = pd.read_csv('./data/手写数字识别.csv')
x = data.iloc[:, 1:]
y = data.iloc[:, 0]
print(Counter(y))  # Counter({1: 4684, 7: 4401, 3: 4351, 9: 4188, 2: 4177, 6: 4137, 0: 4132, 4: 4072, 8: 4063, 5: 3795})

# 2.显示
digit = x.iloc[1].values
img = digit.reshape(28, 28)
plt.imshow(img, cmap='gray')
plt.imsave('./data/digit.png', img)
plt.show()
